package com.mccrea.principle.inversion.improve;

/**
 * @Classname DependencyInversion
 * @Description 依赖倒转
 * @Date 2021/5/6 0006 16:59
 * @Created by Mccrea_Gao
 */
public class DependencyInversion {
    public static void main(String[] args) {
        Person person = new Person();
        person.receive(new QQ());
    }
}

interface IReceive {
    String getInfo();
}

class Email implements IReceive {

    @Override
    public String getInfo() {
        return "电子邮件信息";
    }
}

class QQ implements IReceive {

    @Override
    public String getInfo() {
        return "QQ信息";
    }
}

class Person {
    public void receive(IReceive iReceive) {
        System.out.println(iReceive.getInfo());
    }
}
